package com.lvmama.service.rhino.treestatistic.impl;

import com.lvmama.dao.rhino.treestatic.TreeStatisticsDao;
import com.lvmama.pojo.dto.rhino.CommonStatisticsSqlVO;
import com.lvmama.pojo.dto.rhino.tree.DeviceStatisticsSqlVO;
import com.lvmama.pojo.dto.rhino.tree.NettypeStatisticsSqlVO;
import com.lvmama.pojo.dto.rhino.tree.RegionStatisticsSqlVO;
import com.lvmama.pojo.dto.rhino.tree.StatisticsSqlVO;
import com.lvmama.pojo.entity.rhino.CommonStatisticsResult;
import com.lvmama.pojo.entity.rhino.tree.*;
import com.lvmama.service.rhino.treestatistic.TreeStatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("treeStatisticsService")
@Slf4j
public class TreeStatisticsServiceImpl implements TreeStatisticsService {

    @Autowired
    private TreeStatisticsDao messageMapper;

	@Override
	public List<TreeNodeView> queryAllTreeNodeView() {
		log.info("queryAllTreeNodeView start");
		List<TreeNodeView> viewList = null;
		try {
			viewList = messageMapper.QueryAllTreeNodeView();
		}catch (Exception e){
			log.error("queryAllTreeNodeView error",e.getMessage(),e);
		}
		log.info("queryAllTreeNodeView end");
		return viewList;
	}
	
	@Override
	public List<CodeNode> queryAllCodeNode() {
		log.info("queryAllCodeNode start");
		List<CodeNode> viewList = null;
		try {
			viewList = messageMapper.QueryAllCodeNode();
		}catch (Exception e){
			log.error("queryAllCodeNode error",e.getMessage(),e);
		}
		log.info("queryAllCodeNode end");
		return viewList;
	}
	
	@Override
	public void insertTreeNodeView(TreeNodeView treeNodeView) {
		log.info("insertTreeNodeView start");
		try{
			messageMapper.insertTreeNodeView(treeNodeView);
		}catch (Exception e){
			log.error("insertTreeNodeView error",e.getMessage(),e);
		}
		log.info("insertTreeNodeView end");
	}
	
	@Override
	public void deleteTreeNodeView(TreeNodeView treeNodeView) {
		log.info("deleteTreeNodeView start");
		try{
			messageMapper.deleteTreeNodeView(treeNodeView);
		}catch (Exception e){
			log.error("deleteTreeNodeView error",e.getMessage(),e);
		}
		log.info("deleteTreeNodeView end");
	}
	
	@Override
	public List<String> queryDataByNode(){
		log.info("queryDataByNode start");
		List<String> result = null;
		try {
			result = messageMapper.QueryDataByNode();
		}catch (Exception e){
			log.error("queryDataByNode error",e.getMessage(),e);
		}
		log.info("queryDataByNode end");
		return result;
	}
	
	@Override
	public List<FlowStatisticsResult> queryFlowSticsResByNode(StatisticsSqlVO ss) {
		log.info("queryFlowSticsResByNode start");
		List<FlowStatisticsResult> result = null;
		try {
			result = messageMapper.QueryFlowSticsResByNode(ss);
		}catch (Exception e){
			log.error("queryFlowSticsResByNode error",e.getMessage(),e);
		}
		log.info("queryFlowSticsResByNode end");
		return result;
	}


	@Override
	public List<FlowStatisticsResult> queryFSConversion(StatisticsSqlVO ss) {
		List<FlowStatisticsResult> viewList = null;
		try {
			viewList =  messageMapper.QueryFSConversion(ss);
		}catch (Exception e){
			log.error("queryFSConversion error",e.getMessage(),e);
		}
		log.info("queryFSConversion end");
		return viewList;
	}


	@Override
	public List<DeviceStatisticsResult> queryDeviceFS(DeviceStatisticsSqlVO ss) {
		List<DeviceStatisticsResult> viewList = null;
		try {
			viewList = messageMapper.QueryDeviceFS(ss);
		}catch (Exception e){
			log.error("queryDeviceFS error",e.getMessage(),e);
		}
		return viewList;
	}


	@Override
	public List<NettypeStatisticsResult> queryNettypeFS(NettypeStatisticsSqlVO ss) {
		List<NettypeStatisticsResult> viewList = null;
		try {
			viewList = messageMapper.QueryNettypeFS(ss);
		}catch (Exception e){
			log.error("queryNettypeFS error",e.getMessage(),e);
		}
		return viewList;
	}


	@Override
	public List<RegionStatisticsResult> queryRegionFS(RegionStatisticsSqlVO ss) {
		List<RegionStatisticsResult> viewList = null;
		try{
			viewList =  messageMapper.QueryRegionFS(ss);
		}catch (Exception e){
			log.error("queryRegionFS error",e.getMessage(),e);
		}
		return viewList;
	}
	
	@Override
	public List<CommonStatisticsResult> queryCommonFS(CommonStatisticsSqlVO ss) {
		List<CommonStatisticsResult> viewList = null;
		try {
			viewList =messageMapper.QueryCommonFS(ss);
		}catch (Exception e){
			log.error("queryCommonFS error",e.getMessage(),e);
		}
		return viewList;
	}
}
